#include <cstdio>
#include <cstdlib>
using namespace std;

#define MAX_SIZE 10

void swap_element(int[], int);
void quick_sort(int[], int);
void print_array(int[], int);

int main()
{
    int matrix[MAX_SIZE][MAX_SIZE] = {0};
    int size = 0;

    while (scanf(" %d", &size) != EOF) {
        for (int i = 0; i < size; i++)
            for (int j = 0; j < size; j++)
                scanf(" %d", &matrix[i][j]);

        int result_vector[2 * size + 2] = {0};
        for (int i = 0; i < size; i++)
            for (int j = 0; j < size; j++)
                result_vector[i] += matrix[i][j];
        for (int i = 0; i < size; i++)
            for (int j = 0; j < size; j++)
                result_vector[i + size] += matrix[j][i];
        for (int i = 0; i < size; i++) {
            result_vector[2 * size] += matrix[i][i];
            result_vector[2 * size + 1] += matrix[i][size - i - 1];
        }

        int result_len = 2 * size + 2;
        quick_sort(result_vector, result_len);
        print_array(result_vector, result_len);
    }
}

void swap_element(int array[], int i, int j)
{
    int temp;
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

void quick_sort(int array[], int num)
{
    int i, last = 0;
    if (num <= 1)
        return;
    swap_element(array, 0, rand() % num);
    for (i = 1; i < num; i++) {
        if (array[i] > array[0])
            swap_element(array, ++last, i);
    }

    swap_element(array, 0, last);
    quick_sort(array, last);
    quick_sort(array + last + 1, num - last - 1);
}

void print_array(int array[], int num)
{
    for (int i = 0; i < num; i++)
        printf("%d ", array[i]);
    printf("\n");
}